import React, { useContext } from "react";
import { Button } from "antd";
import { useNavigate } from "react-router-dom";
import { context } from "../../components/AppProvider";

export default function Login() {
  const navigate = useNavigate();
  const { resetMenus } = useContext(context);
  const sign = () => {
    sessionStorage.setItem("token", "token");
    // 刷新页面导致路由以及丢失menu的关键
    sessionStorage.setItem("role", "admin");
    //重置路由菜关键点
    resetMenus("admin");
    // 获取查询参数,如果没有就跳转到首页
    navigate("/layouts/home", { replace: true });
  };
  return (
    <>
      <div className="w-[100vw] h-[100vh] flex">
        <div className="flex-1 max-xl:hidden bg-[#FFF6F6]"></div>
        <div className="flex-1">
          <Button type="primary" onClick={() => sign()}>
            Login
          </Button>
        </div>
      </div>
    </>
  );
}
